/**
 * 
 */
package org.jft.datamodel.database.dao.implementation;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Session;
import org.jft.datamodel.database.HibernateUtil;
import org.jft.datamodel.database.dao.GenericDAO;
import org.jft.datamodel.database.mapping.Person;


/**
 * @author LAP
 *
 */
public class PersonDAO extends GenericDAO<Person> {

	@Override
	public Person getByID(Long id) throws SQLException {
		Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
		Person person = (Person) session.load(Person.class, id);
		return person;
	}
	
	@Override
	public List<Person> getAll() throws SQLException {
		Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
		List<Person> persons = session.createCriteria(Person.class).list();
		return persons;
	}
}
